package com.edais.dao;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.edais.domain.SalesmanMonthRecord;
import com.edais.domain.SalesmanRecord;
import com.edais.persistence.KcodeChannelMapper;

@Repository

public class KcodeChannelDao {
	@Autowired
	private KcodeChannelMapper kcodeChannelMapper;
	
	/**
	 * 
	 * @Description: 通过卡号查询k码和渠道信息
	 * @param @param parmMap
	 * @param @return
	 * @param @throws Exception   
	 * @return Map<String,Object>  
	 * @throws
	 * @author wuhan
	 * @date 2016-7-14
	 */
	public Map<String, Object> selectCardNo(Map<String, Object> parmMap)throws Exception {
		// TODO Auto-generated method stub
		return kcodeChannelMapper.selectCardNo(parmMap);
	}
	
	public Map<String, Object> getKeycodeChannel(Map<String, Object> parmMap)throws Exception {
		return kcodeChannelMapper.getKeycodeChannel(parmMap);
	}

	/**
	 * 
	 * @Description: 通过卡号查询卡号导入参数设置表信息
	 * @param @param parmMap
	 * @param @return
	 * @param @throws Exception   
	 * @return Map<String,Object>  
	 * @throws
	 * @author wuhan
	 * @date 2016-7-14
	 */
	public Map<String, Object> selectTimeCardNo(Map<String, Object> parmMap) throws Exception {
		// TODO Auto-generated method stub
		return kcodeChannelMapper.selectTimeCardNo(parmMap);
	}

	/**
	 * 
	 * @Description: 添加代金券
	 * @param @param map
	 * @param @return   
	 * @return int  
	 * @throws
	 * @author wuhan
	 * @date 2016-7-14
	 */
	public int addVoucher(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return  kcodeChannelMapper.addVoucher(map);
	}

	public List<String> queryParamName(Map<String, String> parammap) {
		// TODO Auto-generated method stub
		return (List<String>)kcodeChannelMapper.queryParamName(parammap);
	}
	
	/**
	 * 
	 * @Description: 查询代金券规则表
	 * @param @param map
	 * @param @return   
	 * @return List<Map<String,Object>>  
	 * @throws
	 * @author wuhan
	 * @date 2016-7-14
	 */
	public List<Map<String, Object>> queryVoucherRule(Map<String, Object> map){
		return kcodeChannelMapper.queryVoucherRule(map);
	}
	
	/**
	 * 
	 * @Description: 修改k码ip归属地信息
	 * @param @param params
	 * @param @throws ServiceException   
	 * @return void  
	 * @throws
	 * @author wuhan
	 * @date 2016-7-20
	 */
	public void updateActivityAreaInfo(Map<String, Object> params){
		kcodeChannelMapper.updateActivityAreaInfo(params);
	}
	
	/**
	 * 
	 * @Description: 修改k码gps信息
	 * @param @param params
	 * @param @throws ServiceException   
	 * @return void  
	 * @throws
	 * @author wangdanqing
	 * @date 2016-7-20
	 */
	public void updateActivityGpsInfo(Map<String, Object> params) throws Exception {
		kcodeChannelMapper.updateActivityGpsInfo(params);
	}
	
	/**
	 * 查询会员表信息
	 * @Description: TODO
	 * @param  memberMap
	 * @param @return
	 * @param @throws Exception   
	 * @return List<Map<String,Object>>  
	 * @throws
	 * @author wuhan
	 * @date 2016-8-24
	 */
	public List<Map<String, Object>> queryMemberInfoList(Map<String,Object> memberMap) throws Exception{
		return kcodeChannelMapper.queryMemberInfoList(memberMap);
	}
	
	/**
	 * 添加销售人员返佣记录信息
	 * @Description: TODO
	 * @param @param memberMap
	 * @param @throws Exception   
	 * @return void  
	 * @throws
	 * @author wuhan
	 * @date 2016-8-24
	 */
	public void addSalesmanRecord(Map<String,Object> memberMap) throws Exception{
		kcodeChannelMapper.addSalesmanRecord(memberMap);
	}
	
	/**
	 * 根据月份查询返佣信息
	 * @Description: TODO
	 * @param @param memberMap
	 * @param @return
	 * @param @throws Exception   
	 * @return List<Map<String,Object>>  
	 * @throws
	 * @author wuhan
	 * @date 2016-8-25
	 */
	public List<SalesmanRecord>  querySaleManRecordListByDate(Map<String,Object> memberMap) throws Exception{
		//获取分页参数
		int current = Integer.parseInt(memberMap.get("current")+"");
		int pageSize = Integer.parseInt(memberMap.get("pageSize")+"");
		//组装起始条数
		memberMap.put("rowBegin",(current-1)*pageSize + 1);
		memberMap.put("rowEnd",current*pageSize);
		
		return kcodeChannelMapper.querySaleManRecordListByDate(memberMap);
	}
	
	/**
	 * 根据月份查询返佣信息总数
	 * @Description: TODO
	 * @param @param memberMap
	 * @param @return
	 * @param @throws Exception   
	 * @return int  
	 * @throws
	 * @author wuhan
	 * @date 2016-8-29
	 */
	public int querySaleManRecordListByDateCount(Map<String,Object> memberMap) throws Exception{
		return kcodeChannelMapper.querySaleManRecordListByDateCount(memberMap);
	}
	
	/**
	 * 统计销售人员每月销售数据
	 * @Description: TODO
	 * @param @param memberMap
	 * @param @return
	 * @param @throws Exception   
	 * @return List<SalesmanMonthRecord>  
	 * @throws
	 * @author wuhan
	 * @date 2016-9-1
	 */
	public List<SalesmanMonthRecord> querySalesmanMonthRecord(Map<String,Object> memberMap) throws Exception{
		//获取分页参数
		int current = Integer.parseInt(memberMap.get("current")+"");
		int pageSize = Integer.parseInt(memberMap.get("pageSize")+"");
		//组装起始条数
		memberMap.put("rowBegin",(current-1)*pageSize + 1);
		memberMap.put("rowEnd",current*pageSize);
		
		return kcodeChannelMapper.querySalesmanMonthRecord(memberMap);
	}
	
	
	/**
	 * 统计销售人员每月销售数据总数
	 * @Description: TODO
	 * @param @param memberMap
	 * @param @return
	 * @param @throws Exception   
	 * @return int  
	 * @throws
	 * @author wuhan
	 * @date 2016-9-1
	 */
	public int querySalesmanMonthRecordCount(Map<String,Object> memberMap) throws Exception{
		return kcodeChannelMapper.querySalesmanMonthRecordCount(memberMap);
	}
	
	/**
	 * @Description 查询不可激活的k码
	 * @param params
	 * @return Map
	 * @throws Exception
	 * @author wuhan
	 * @date 2016-11-14
	 */
	public int selectIllegal(Map<String,Object> params) throws Exception{
		return kcodeChannelMapper.selectIllegal(params);
	}
	
	
	/**
	 * 查询卡号是否存在
	 * @param cardNo
	 * @return int
	 */
	public int queryKeyCodeCountByCardNo(String cardNo){
		return kcodeChannelMapper.queryKeyCodeCountByCardNo(cardNo);
	}
	
	/**
	 * 查询渠道是否存在
	 * @param param 渠道id 渠道名称
	 * @return
	 */
	public int queryChannelCountByParam(Map<String, Object> param){
		return kcodeChannelMapper.queryChannelCountByParam(param);
	}
	
	/**
	 * 删除无效k码记录表
	 * @param cardNo
	 * @return
	 */
	public int updateKcodeIllegalByCardNo(String cardNo){
		return kcodeChannelMapper.updateKcodeIllegalByCardNo(cardNo);
	}
	
	/**
	 * 添加k码信息
	 * @param kcodeMap
	 * @return
	 */
	public int insertKeycodeInfo(Map<String, Object> kcodeMap){
		return kcodeChannelMapper.insertKeycodeInfo(kcodeMap);
	}
	
	
}
